﻿using System.IO;
using System.Linq;
using GlobalizationTools.Model;

namespace GlobalizationTools.ViewModel
{
    public class TreeViewSolutionViewModel : TreeViewItemViewModel
    {

        Solution _solution;

        public TreeViewSolutionViewModel(TreeViewRootViewModel root, Solution solution) :
            base(root, true, true)
        {
            _solution = solution;
            _name = Path.GetFileNameWithoutExtension(_solution.FilePath);
        }

        protected override void LoadChildrenInternal()
        {
            _solution.LoadSolution();
            foreach (Project project in _solution.Projects.OrderBy(T => T.ProjectName))
            {
                TreeViewProjectViewModel model = new TreeViewProjectViewModel(this, project);
                _children.Add(model);
            }
        }

        public Solution Solution
        {
            get { return _solution; }
        }


    }
}
